import { notFound } from "next/navigation"; import type { ReactNode } from "react"; import { api } from "@/lib/api"; /** * Existence check outside the `loading.tsx` boundary: the page streams behind a skeleton, so a * `notFound()` thrown there would arrive after the 200 shell. Checking here yields a real 404. * (The page's own `api.entity()` call is deduplicated by the fetch memoization of the same render.) */ export default async function EntityLayout({ params, children }: { params: Promise<{ id: string }>; children: ReactNode }) { const { id } = await params; const d = await api.entity(id); if (!d) notFound(); return children; }